<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', 'Controller@clearCache');
/**
 * 后台路由
 */
Route::group(['prefix'=>'admin', 'namespace'=>'Admin'], function () {
    //需登录路由
    Route::group(['middleware'=>'admin.auth'], function () {
        //无权限显示
        Route::get('np', function () {
            return view('admin.np');
        });
        Route::get('logout', 'AuthController@logout');
        //自动首页
        Route::get('/', 'IndexController@index');
        //消息中心
        Route::get('notify/{type?}', 'NotifyController@index')->where('type', 'unread|all');
        //验证权限的路由
        Route::group(['middleware'=>'admin.role'], function () {
            //仪表盘
            Route::get('/dashboard', 'DashController@dashboard');
            //用户管理
            Route::get('/user', 'UserController@index');
            //内容管理
            Route::get('/content', 'ContentController@index');
            //爬虫管理
            Route::get('/spider', 'SpiderController@index');
            //权限管理
            Route::get('/power', 'PowerController@index');
            //角色管理
            Route::get('/role', 'RoleController@index');
            //管理员管理
            Route::get('/admin', 'AdminController@index');
            //日志管理
            Route::get('/log', 'LogController@index');
            //审核管理
            Route::get('/pending', 'PendController@index');
            //网站设置
            Route::get('/setting', 'SetController@index');
            //积分策略
            Route::get('/cplane', 'CPlaneController@index');
        });
    });
    //无需登录路由
    Route::get('login', ['middleware'=>'guest:admin', 'uses'=>'AuthController@showLoginForm']);
    //异步路由
    Route::group(['prefix'=>'ajax'], function () {
        //登录路由
        Route::post('login', 'AuthController@login');
        //获取消息树
        Route::post('notification', 'AjaxController@notification');
        //标记已读消息
        Route::post('flag', 'AjaxController@flagNotify');
        //获取更多消息
        Route::post('moreNotify', 'AjaxController@moreNotify');
    });
});

/**
 * 前台路由
 */
Route::group(['middleware'=>'home.auth', 'namespace'=>'Home'], function () {
    //个人中心
    Route::get('profile', 'ProfileController@index');
    //个人信息修改
    Route::get('profile/edit', 'ProfileController@edit');
    //异步群组
    Route::group(['prefix'=>'ajax'], function () {
        Route::post('upload', 'AjaxController@upload');
    });
});